import 'package:flutter/material.dart';
import 'package:fluro/fluro.dart';
import 'package:jiaju_flutter/pages/home/index.dart';
import 'package:jiaju_flutter/pages/login/index.dart';
import 'package:jiaju_flutter/pages/master/index.dart';
import 'package:jiaju_flutter/pages/not_found.dart';
import 'package:jiaju_flutter/pages/registor/index.dart';
import 'package:jiaju_flutter/pages/room/index.dart';

class Routes {
  static const master = "/";
  static const home = "/home";
  static const login = "/login";
  static const registor = "/registor";
  static const mine = "/mine";
  static const room_details = "/room_details/:roomId";

  static final _notFoundHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return NotFoundPage();
  });

  static final _masterHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return MasterPage();
  });

  static final _homeHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return HomePage();
  });

  static final _loginHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return LoginPage();
  });

  static final _registorHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RegistorPage();
  });

  static final _roomDetailsHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RoomDetailsPage(
      roomId: params['roomId'][0],
    );
  });

  static void defineRoutes(FluroRouter router) {
    router.notFoundHandler = _notFoundHandler;
    router.define(master, handler: _masterHandler);
    router.define(home, handler: _homeHandler);
    router.define(login,
        handler: _loginHandler, transitionType: TransitionType.material);
    router.define(room_details, handler: _roomDetailsHandler);
    router.define(registor, handler: _registorHandler);
  }
}
